# ~*~ coding: utf-8 ~*~
from apps.common.dbbase import BaseModel
from apps.extensions import db

__all__ = ['Session']


class Session(BaseModel):
    __tablename__ = 'terminal_session'

    id = db.Column(db.CHAR(36), primary_key=True)
    user = db.Column(db.VARCHAR(128))
    asset = db.Column(db.VARCHAR(1024))
    system_user = db.Column(db.VARCHAR(128))
    login_from = db.Column(db.CHAR(2), default="ST")
    remote_addr = db.Column(db.VARCHAR(126), nullable=True)
    is_finished = db.Column(db.Boolean, default=False)
    protocol = db.Column(db.VARCHAR(8), default="ssh")
    record_path = db.Column(db.VARCHAR(256))

    date_start = db.Column(db.Integer, nullable=False)
    date_end = db.Column(db.Integer, nullable=True)

    def __str__(self):
        return "<Session: {}>".format(self.id)


